﻿using SpecFlowDemo.Specs.Support.Drivers;
using System.Net.Http;
using System.Threading.Tasks;
using TechTalk.SpecFlow;

namespace SpecFlowDemo.Specs.Support.Hooks
{
    [Binding]
    public sealed class IdentityServerHook
    {
        private readonly HttpClientDriver _httpClientDriver;
        private readonly HttpClient _httpClient;

        public IdentityServerHook(HttpClientDriver httpClientDriver, IHttpClientFactory _httpClientFactory)
        {
            _httpClientDriver = httpClientDriver;
            _httpClient = _httpClientFactory.CreateClient();
        }

        [BeforeTestRun]
        public static async Task BeforeTestRun()
        {
            //开启mock服务
        }

        [AfterTestRun]
        public static async Task AfterTestRun()
        {
            //停止mock服务
        }

        [BeforeScenario("Authentication")]
        public async Task Authentication()
        {
            _httpClientDriver.TestSSS = "222";
            await _httpClientDriver.Login();
        }
    }
}
